package com.itcast.mybatis.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.itcast.mybatis.mapper.CourseBaseMapper;
import com.itcast.mybatis.model.CourseBase;
import com.itcast.mybatis.service.CourseBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/coursebase")
public class CourseBaseController {

    @Autowired
    private CourseBaseMapper courseBaseMapper;

    @Autowired
    private CourseBaseService courseBaseService;

    @RequestMapping("/findall")
    public List<CourseBase> findAll() {
        return courseBaseMapper.selectAll();
    }

    @RequestMapping("/findpage")
    public PageInfo<CourseBase> findPage(int page, int rows) {
        PageHelper.startPage(page, rows);
        return new PageInfo<>(courseBaseMapper.selectAll());
    }

    @RequestMapping("/testtrans")
    public void saveTrans() {
        courseBaseService.saveCourseBaseByTrans();
    }
}
